package Interview.toutiao;


import domain.ListNode;

/**
 * 反转链表
 * @author leiwenkang
 * @date 2020/4/5
 */
public class Test04 {
    public ListNode reverseListNode(ListNode head) {
        ListNode p = head;
        ListNode pre = null;
        while (p != null) {
            ListNode next = p.next;
            p.next = pre;
            pre = p;
            p = next;
        }
        return pre;
    }
}
